package cc.vv.btpartyjob.partymanager.delegate

import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.View
import android.widget.TextView
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.partymanager.R
import cc.vv.btpartyjob.partymanager.adapter.PartyRegisterAdapter
import cc.vv.btpartyjob.partymanager.adapter.RegisterAddressChooseAdapter
import cc.vv.btpartyjob.partymanager.moudel.bean.CommunityActivitiesBean
import cc.vv.mvp.delegate.BaseAppDelegate
import com.chad.library.adapter.base.BaseQuickAdapter

/**
 * 报到街道、社区祖选择托管类
 * Created by Chen.qi on 2018/10/24.
 */
class RegisterAddressChooseActivityDelegate : BaseAppDelegate() {

    /**
     * 网格适配器
     */
    private var mAdapter: RegisterAddressChooseAdapter? = null

    override fun initWidget() {
        mAdapter = RegisterAddressChooseAdapter(R.layout.item_register_address_choose)
        val recyclerView = getView<RecyclerView>(R.id.rv_araC_listData)
        recyclerView.layoutManager = LinearLayoutManager(getActivity())
        recyclerView.adapter = mAdapter
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_register_address_choose
    }

    /**设置标题title*/
    fun setTopBarTitle(topBarTitle: String) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_araC_topBar)
        titleBar?.setTitle(topBarTitle)
    }


    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_araC_topBar)
        titleBar?.setEventInterface(event)
    }

    /** 党员报到数据适配器 */
    fun setAdapterData(list: List<String>?) {
        if (null != list && list.isNotEmpty()) {
            mAdapter?.setNewData(list)
        } else {
            showNoDataView()
        }
    }

    /** 显示暂无数据缺省页 */
    private fun showNoDataView() {
        getView<TextView>(R.id.btv_araC_listNoData)?.visibility = View.VISIBLE
    }


    /** 设置列表 Item 点击事件*/
    fun bindOnItemClick(onItemClickListener: BaseQuickAdapter.OnItemClickListener) {
        mAdapter?.onItemClickListener = onItemClickListener
    }

}